– The outputs for R notebook and R markdown are rather similiar. Writing an R Notebook document is no different than writing an R Markdown document. The text and code chunk syntax does not differ at all. The main difference is that when executing chunks in an R Markdown document, all the code is sent to the console at once, but in an R Notebook, only one line at a time is sent. This allows execution to stop if a line raises an error. Also R markdown uses knit to run all the R code chunks and create a document, while the notebook uses preview, which shows you only a rendered HTML copy of the contents of the editor. Also, unlike Knit, Preview does not run any R code chunks.
– The only difference in input is the section under “output” at the head of the file that changes depending on which type of document you are knitting to. As for output, each document is conveying the same information, but because they are put into completly different formats they differ quite a bit. Word looks the best to me, but I think I have some bias due to using primarly word for making nice papers.
I went to Kaggle and found some data to work on!
My data is on the top songs from spotify over the last 10 years!
Here is a link to where I found the data: https://www.kaggle.com/leonardopena/top-spotify-songs-from-20102019-by-year/metadata
– Time for some data analysis!
setwd("~/Rmarkdown1_Carson_Green")
library(readr)
top10s <- read_csv("top10s.csv")
## Parsed with column specification:
## cols(
## X1 = col_double(),
## title = col_character(),
## artist = col_character(),
## `top genre` = col_character(),
## year = col_double(),
## bpm = col_double(),
## nrgy = col_double(),
## dnce = col_double(),
## dB = col_double(),
## live = col_double(),
## val = col_double(),
## dur = col_double(),
## acous = col_double(),
## spch = col_double(),
## pop = col_double()
## )
songs <- top10s
head(songs)
## # A tibble: 6 x 15
## X1 title artist `top genre` year bpm nrgy dnce dB live val
## <dbl> <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1 Hey,~ Train neo mellow 2010 97 89 67 -4 8 80
## 2 2 Love~ Eminem detroit hi~ 2010 87 93 75 -5 52 64
## 3 3 TiK ~ Kesha dance pop 2010 120 84 76 -3 29 71
## 4 4 Bad ~ Lady ~ dance pop 2010 119 92 70 -4 8 71
## 5 5 Just~ Bruno~ pop 2010 109 84 64 -5 9 43
## 6 6 Baby Justi~ canadian p~ 2010 65 86 73 -5 11 54
## # ... with 4 more variables: dur <dbl>, acous <dbl>, spch <dbl>, pop <dbl>
str(songs)
## Classes 'spec_tbl_df', 'tbl_df', 'tbl' and 'data.frame': 603 obs. of 15 variables:
## $ X1 : num 1 2 3 4 5 6 7 8 9 10 ...
## $ title : chr "Hey, Soul Sister" "Love The Way You Lie" "TiK ToK" "Bad Romance" ...
## $ artist : chr "Train" "Eminem" "Kesha" "Lady Gaga" ...
## $ top genre: chr "neo mellow" "detroit hip hop" "dance pop" "dance pop" ...
## $ year : num 2010 2010 2010 2010 2010 2010 2010 2010 2010 2010 ...
## $ bpm : num 97 87 120 119 109 65 120 148 93 126 ...
## $ nrgy : num 89 93 84 92 84 86 78 76 37 72 ...
## $ dnce : num 67 75 76 70 64 73 75 52 48 79 ...
## $ dB : num -4 -5 -3 -4 -5 -5 -4 -6 -8 -4 ...
## $ live : num 8 52 29 8 9 11 4 12 12 7 ...
## $ val : num 80 64 71 71 43 54 82 38 14 61 ...
## $ dur : num 217 263 200 295 221 214 203 225 216 235 ...
## $ acous : num 19 24 10 0 2 4 0 7 74 13 ...
## $ spch : num 4 23 14 4 4 14 9 4 3 4 ...
## $ pop : num 83 82 80 79 78 77 77 77 76 73 ...
## - attr(*, "spec")=
## .. cols(
## .. X1 = col_double(),
## .. title = col_character(),
## .. artist = col_character(),
## .. `top genre` = col_character(),
## .. year = col_double(),
## .. bpm = col_double(),
## .. nrgy = col_double(),
## .. dnce = col_double(),
## .. dB = col_double(),
## .. live = col_double(),
## .. val = col_double(),
## .. dur = col_double(),
## .. acous = col_double(),
## .. spch = col_double(),
## .. pop = col_double()
## .. )
– About my Data:
603 observations of 15 variables:
title - Song’s title
artist - Song’s artist
top genre - the genre of the track
year - Song’s year in the Billboard
bpm - Beats.Per.Minute - The tempo of the song.
nrgy - Energy - The energy of a song - the higher the value, the more energtic.
dnce - Danceability - The higher the value, the easier it is to dance to this song.
dB - Loudness..dB.. - The higher the value, the louder the song
live - Liveness - The higher the value, the more likely the song is a live recording
val - Valence - The higher the value, the more positive mood for the song.
dur - Length - The duration of the song.
acous - Acousticness.. - The higher the value the more acoustic the song is.
spch - Speechiness - The higher the value the more spoken word the song contains.
pop - Popularity- The higher the value the more popular the song is.
– Time to plot stuff I’m intrested in!